//=============顶部下拉菜单处理==================
$(function(){		   
	var esParam = esParam || {};
	esParam.lbTime = null;
	esParam.lb = $('#topNav div.listbox');
	esParam.lbIndex = null;
	$('#topNavMenu>li>a').mouseover(function() {
		var t = $(this);
		var lb = t.next('div');
		var lbindex = parseInt(lb.attr('lbindex'));
	
		if(esParam.lbTime != null && esParam.lbIndex == lbindex) {
			clearTimeout(esParam.lbTime);
		} else {
			esParam.lb.hide();
		}
		t.parent().addClass('cur');
		lb.show();
	}).mouseout(function() {
		var t = $(this);
		var lb = t.next('div');
		t.parent().removeClass('cur');
		esParam.lbIndex = parseInt(lb.attr('lbindex'));
		esParam.lbTime = setTimeout(function() {
			lb.hide();
		}, 20);
	});
	$('#topNavMenu>li>div').mouseover(function() {
		var t = $(this);
		t.parent().addClass('cur');
		if(esParam.lbTime != null) {
			clearTimeout(esParam.lbTime);
		}
		t.show();
	}).mouseout(function() {
		var t = $(this);
		t.parent().removeClass('cur');
		esParam.lbTime = setTimeout(function() {
			t.hide();
		}, 20);
	});
	$('#btnSearch').mouseover(function(){
		$(this).addClass('btnHover');
	}).mouseout(function(){
		$(this).removeClass('btnHover');
	});

})
/*
 * 获取会员登录信息网站前台通用
 * */
$(function(){  
	var sMemberUrl = $("#memberUrlHid").val()?$("#memberUrlHid").val():"http://member.esunny.com";	
	/* 未登录过时不请求登录信息 */
	var logon = getCookieByKey("logon");
	if (!logon || logon=="") {
		$("#topNavWel").html("<span class='lg'><a title='登录' href='"+sMemberUrl+"/login.htm'>登录</a>/<a href='"+sMemberUrl+"/firm_join.htm' title='注册'>注册</a></span>")
		return;
	}
	
	var time = new Date().getTime();
	var sActionUrl = sMemberUrl + "/member/login_info.htm?infoType=simple&t=" + time;
	$.ajax({
		   type: "get",
		   url: sActionUrl,
		   dataType: "jsonp",
		   jsonp: "callback",
		   success: function(json){
				if (json) {
					var sIsLogon = json.isLogon;
					var sName = json.name;
					var sMemberLevel = json.memberLevel;
					var sServiceYears = json.serviceYears;
					var lUnreadMessage = json.unreadMessage;
					
					if (sIsLogon=="true") {
						$("#topNavWel").html("欢迎您，<a title='进入我的商务中心' href='"+sMemberUrl+"/member/user_center.htm' class='name'>"+sName+"</a>&nbsp;<a title='退出' href='"+sMemberUrl+"/logout.htm' class='blue'>[退出]</a><a class='msg' href='"+sMemberUrl+"/message/inbox.htm'>站内消息(<span class='orgb'>"+lUnreadMessage+"</span>)</a>");
					
					} else {
						$("#topNavWel").html("<span class='lg'><a title='登录' href='"+sMemberUrl+"/login.htm'>登录</a>/<a href='"+sMemberUrl+"/firm_join.htm' title='注册'>注册</a></span>");
					}
				}
		   }
		});
       
});

/* 获取指定名称的cookie的值 */
function getCookieByKey(key){
   var cookieArr = document.cookie.split("; ");
   for(var i = 0;i < cookieArr.length;i ++){
   	var item = cookieArr[i].split("=");
    if(item[0] == key) return unescape(item[1]);
   } 
}

//==================搜索======================
var serachFn = {}
serachFn.topsearchFn = function() {
	var txtSearchWord = $('#searchForm>span>input'), 
		tagItem = $('#searchTag>li');
		
	var urlsearchweb = $("#urlsearchweb").val() ? $("#urlsearchweb").val() : "http://search.esunny.com",
		searchType = $("#searchTarget").val() ? $("#searchTarget").val() : 1,
		noKeyWordTip = "请输入产品名",
		offerKeyWord = "请输入产品名",
		buyofferKeyWord = "请输入产品名称或关键字",
		companyKeyWord = "请输入公司名称或关键字";

	if( typeof (SearchArgs) != 'undefined' && SearchArgs.KeyWord.length != 0) {
		txtSearchWord.val(SearchArgs.KeyWord);
	}

	tagItem.bind('click', function(e) {
		e = e || window.event;
		var target = $(e.target || e.srcElement).parent();
		tagItem.removeClass('cur');
		
		searchType = target.addClass('cur').attr('id').replace('li0', '');
		
		if($.trim(txtSearchWord.val()) == '' || $.trim(txtSearchWord.val()) == noKeyWordTip || $.trim(txtSearchWord.val()) == offerKeyWord || $.trim(txtSearchWord.val()) == buyofferKeyWord || $.trim(txtSearchWord.val()) == companyKeyWord) {
			if(searchType == 1) {
				txtSearchWord.val(offerKeyWord);
			} else if(searchType == 2) {
				txtSearchWord.val(buyofferKeyWord);
			} else if(searchType == 3) {
				txtSearchWord.val(companyKeyWord);
			} else {
				txtSearchWord.val(noKeyWordTip);
			}
		}
	});
	
	txtSearchWord.focus(function() {
		var t = $(this);
		if($.trim(t.val()) == noKeyWordTip || $.trim(t.val()) == offerKeyWord || $.trim(t.val()) == buyofferKeyWord || $.trim(t.val()) == companyKeyWord) {
			t.val('');
		}
		t.css("color", "#313131");
	}).blur(function() {
		var t = $(this);
		if($.trim(t.val()) == '') {
			t.css("color", "");
			if(searchType == 1) {
				t.val(offerKeyWord);
			} else if(searchType == 2) {
				t.val(buyofferKeyWord);
			} else if(searchType == 3) {
				t.val(companyKeyWord);
			} else {
				t.val(noKeyWordTip);
			}
		} else {
			t.css("color", "#313131");
		}
	}).keydown(function(e) {
		e = e || window.event;
		var keyCode = e.keyCode || e.which || e.charCode;
		if(keyCode == 13) {
			e.preventDefault();
			var keyWord = $.trim(txtSearchWord.val().toString())
			return doSearch(keyWord);
		}
	});

	$('#btnSearch').click(function() {
		var keyWord = $.trim(txtSearchWord.val().toString())
		return doSearch(keyWord);
	});

	function doSearch(keyWord) {
		var search_txt = $.trim(keyWord);
		var len = 0;
		for(var i = 0; i < search_txt.length; i++) {
			if(search_txt.charCodeAt(i) >= 20224 && search_txt.charCodeAt(i) <= 41125) {
				len += 2;
			} else {
				len++;
			}
		}
		if(search_txt.length > 88) {
			return false;
		}
		if(search_txt == noKeyWordTip || search_txt == offerKeyWord || search_txt == buyofferKeyWord || search_txt == companyKeyWord) {
			search_txt = '';
		}
		switch(parseInt(searchType)) {
			case 1:
				//供应
				search_txt.length > 0 ? window.location.href = encodeURI(urlsearchweb + "/offer/query.htm?q=" + search_txt) : window.location.href = "http://www.esunny.com";
				break;
			case 2:
				//求购
				search_txt.length > 0 ? window.location.href = encodeURI("http://wpbuy.esunny.com/Search?keyword=" + search_txt) : window.location.href = "http://www.esunny.com";
				break;
			case 3:
				//公司
				search_txt.length > 0 ? window.location.href = encodeURI(urlsearchweb + "/company/query.htm?q=" + search_txt) : window.location.href = "http://www.esunny.com";
				break;
			case 4:
				window.location.href = "http://www.esunny.com";
				break;
		}
		return true;
	}
}
serachFn.topsearchFn = function() {
    var txtSearchWord = $('#searchForm>span>input'),
        tagItem = $('#searchTag>li');

    var urlsearchweb = $("#urlsearchweb").val() ? $("#urlsearchweb").val() : "http://search.esunny.com",
        searchType = $("#searchTarget").val() ? $("#searchTarget").val() : 1,
        noKeyWordTip = "请输入产品名",
        offerKeyWord = "请输入产品名",
        buyofferKeyWord = "请输入产品名称或关键字",
        companyKeyWord = "请输入公司名称或关键字";

    if( typeof (SearchArgs) != 'undefined' && SearchArgs.KeyWord.length != 0) {
        txtSearchWord.val(SearchArgs.KeyWord);
    }

    tagItem.bind('click', function(e) {
        e = e || window.event;
        var target = $(e.target || e.srcElement).parent();
        tagItem.removeClass('cur');

        searchType = target.addClass('cur').attr('id').replace('li0', '');

        if($.trim(txtSearchWord.val()) == '' || $.trim(txtSearchWord.val()) == noKeyWordTip || $.trim(txtSearchWord.val()) == offerKeyWord || $.trim(txtSearchWord.val()) == buyofferKeyWord || $.trim(txtSearchWord.val()) == companyKeyWord) {
            if(searchType == 1) {
                txtSearchWord.val(offerKeyWord);
            } else if(searchType == 2) {
                txtSearchWord.val(buyofferKeyWord);
            } else if(searchType == 3) {
                txtSearchWord.val(companyKeyWord);
            } else {
                txtSearchWord.val(noKeyWordTip);
            }
        }
    });

    txtSearchWord.focus(function() {
        var t = $(this);
        if($.trim(t.val()) == noKeyWordTip || $.trim(t.val()) == offerKeyWord || $.trim(t.val()) == buyofferKeyWord || $.trim(t.val()) == companyKeyWord) {
            t.val('');
        }
        t.css("color", "#313131");
    }).blur(function() {
            var t = $(this);
            if($.trim(t.val()) == '') {
                t.css("color", "");
                if(searchType == 1) {
                    t.val(offerKeyWord);
                } else if(searchType == 2) {
                    t.val(buyofferKeyWord);
                } else if(searchType == 3) {
                    t.val(companyKeyWord);
                } else {
                    t.val(noKeyWordTip);
                }
            } else {
                t.css("color", "#313131");
            }
        }).keydown(function(e) {
            e = e || window.event;
            var keyCode = e.keyCode || e.which || e.charCode;
            if(keyCode == 13) {
                e.preventDefault();
                var keyWord = $.trim(txtSearchWord.val().toString())
                return doSearch(keyWord);
            }
        });

    $('#btnSearch').click(function() {
        var keyWord = $.trim(txtSearchWord.val().toString())
        return doSearch(keyWord);
    });

    function doSearch(keyWord) {
        var search_txt = $.trim(keyWord);
        var len = 0;
        for(var i = 0; i < search_txt.length; i++) {
            if(search_txt.charCodeAt(i) >= 20224 && search_txt.charCodeAt(i) <= 41125) {
                len += 2;
            } else {
                len++;
            }
        }
        if(search_txt.length > 88) {
            return false;
        }
        if(search_txt == noKeyWordTip || search_txt == offerKeyWord || search_txt == buyofferKeyWord || search_txt == companyKeyWord) {
            search_txt = '';
        }
        switch(parseInt(searchType)) {
            case 1:
                //供应
                search_txt.length > 0 ? window.location.href = encodeURI(urlsearchweb + "/offer/query.htm?q=" + search_txt) : window.location.href = "http://www.esunny.com";
                break;
            case 2:
                //求购
                search_txt.length > 0 ? window.location.href = encodeURI("http://wpbuy.esunny.com/Search?keyword=" + search_txt) : window.location.href = "http://www.esunny.com";
                break;
            case 3:
                //公司
                search_txt.length > 0 ? window.location.href = encodeURI(urlsearchweb + "/company/query.htm?q=" + search_txt) : window.location.href = "http://www.esunny.com";
                break;
            case 4:
                window.location.href = "http://www.esunny.com";
                break;
        }
        return true;
    }
}
serachFn.bottomsearchFn = function() {
    //底部搜索事件
    var b_sTxt = $("#b_search_txt"),
        b_tag = $('#b_header_search'),
        b_tagItem = b_tag.find('li');
    b_tagItem.bind('click', function(e) {
        e = e || window.event;
        var target = $(e.target || e.srcElement);
        b_tagItem.removeClass('cur');
        searchType = target.addClass('cur').attr('id').replace('b_li0', '');
        if($.trim(b_sTxt.val()) == '' || $.trim(b_sTxt.val()) == noKeyWordTip || $.trim(b_sTxt.val()) == offerKeyWord || $.trim(b_sTxt.val()) == buyofferKeyWord || $.trim(b_sTxt.val()) == companyKeyWord)
        {
            if(searchType == 1){
                b_sTxt.val(offerKeyWord);
            }else if(searchType==2)
            {
                b_sTxt.val(buyofferKeyWord);
            }else if(searchType ==3){
                b_sTxt.val(companyKeyWord);
            }else{
                b_sTxt.val(noKeyWordTip);
            }
        }
    });
    b_sTxt.click(function(){
        var t = $(this);
        if($.trim(t.val()) == noKeyWordTip || $.trim(t.val()) == offerKeyWord || $.trim(t.val()) == buyofferKeyWord || $.trim(t.val()) == companyKeyWord){
            t.val('');
        }
    }).blur(function(){
            var t = $(this);
            if($.trim(t.val()) == ''){
                if(searchType == 1){
                    t.val(offerKeyWord);
                }else if(searchType==2)
                {
                    t.val(buyofferKeyWord);
                }else if(searchType ==3){
                    t.val(companyKeyWord);
                }else{
                    t.val(noKeyWordTip);
                }
            }
        }).keydown(function(e){
            e = e || window.event;
            if(e.keyCode == 13){
                e.preventDefault();
                var keyWord = $.trim(b_sTxt.val().toString())
                return doSearch(keyWord);
            }
        });

    $("#b_search_button").click(function() {
        var keyWord = $.trim(b_sTxt.val().toString())
        return doSearch(keyWord);
    });

    function doSearch(keyWord){
        var search_txt = $.trim(keyWord);
        var len = 0;
        for (var i=0; i<search_txt.length; i++) {
            if (search_txt.charCodeAt(i)>=20224 && search_txt.charCodeAt(i)<=41125)
            {
                len += 2;
            }else
            {
                len ++;
            }
        }
        if(search_txt.length>88){
            return false;
        }
        if(search_txt == noKeyWordTip || search_txt == offerKeyWord || search_txt == buyofferKeyWord || search_txt == companyKeyWord){
            search_txt = '';
        }
        switch(parseInt(searchType)){
            case 1://供应
                search_txt.length > 0
                    ? window.location.href = urlsearchweb+"/offer/query.htm?q="+encodeURI(search_txt)
                    : window.location.href = "http://www.esunny.com";
                break;
            case 2://求购
                search_txt.length > 0
                    ? window.location.href = "http://wpbuy.esunny.com/Search?keyword="+search_txt
                    : window.location.href = "http://www.esunny.com";
                break;
            case 3://公司
                search_txt.length > 0
                    ? window.location.href = urlsearchweb+"/company/query.htm?q="+encodeURI(search_txt)
                    : window.location.href = "http://www.esunny.com";
                break;
            case 4:
                window.location.href = "http://www.esunny.com";
                break;
        }
        return true;
    }
    function setKeyWord() {
        if (typeof (SearchArgs) != 'undefined' && SearchArgs.KeyWord.length != 0) {
            sTxt.val(SearchArgs.KeyWord);
        }
    }

    function UrlEncode(keyWord) {
        var encodeillegalChars = ['%25', '%26', '*', '%3F', '%3A', '%3C', '%3E', '%23', '%5C', '%2F', '%7C', '%22', "%2B", "_", "."];
        var illegalChars = ['%', '&', '*', '?', ':', '>', '<', '#', '\\', '\/', '|', '"', "+", "_", "."];
        var encodeStrs = encodeURIComponent(keyWord.replace(/(^\s)|(\s$)/g, ""));

        for (var i = 0; i < encodeillegalChars.length; i++) {
            var rx = new RegExp("\\" + encodeillegalChars[i], "ig");
            encodeStrs = encodeStrs.replace(rx, '=' + illegalChars[i].charCodeAt(0).toString(16).toUpperCase());
        }
        return encodeStrs;
    }

    function UrlDecode(keyWord) {
        var encodeillegalChars = ['%25', '%26', '*', '%3F', '%3A', '%3C', '%3E', '%23', '%5C', '%2F', '%7C', '%22', "%2B", "_", "."];
        var illegalChars = ['%', '&', '*', '?', ':', '>', '<', '#', '\\', '\/', '|', '"', "+", "_", "."];
        var encodeStrs = keyWord;
        for (var i = 0; i < illegalChars.length; i++) {
            var rx = new RegExp("=" + illegalChars[i].charCodeAt(0).toString(16).toUpperCase(), "ig");
            encodeStrs = encodeStrs.replace(rx, encodeillegalChars[i]);
        }
        encodeStrs = decodeURIComponent(encodeStrs);
        return encodeStrs;
    }
}
//调用搜索函数
$(function(){
	serachFn.topsearchFn()
    serachFn.bottomsearchFn()
})

$(function(){
//顶部下拉菜单		   
	$(".r_nav_li").hover(function(){
	var _link = $(this).find("s");
	$(this).addClass("r_nav_li_cur");
	_link.addClass("s-cur");
},
function(){
	var _link = $(this).find("s");
	$(this).removeClass("r_nav_li_cur");
	_link.removeClass("s-cur");
});	  
	
//关闭广告
$("#topadClose").bind("click",function(){$(this).parent().slideUp();}).hover(function(){$(this).addClass("top-ad-close-h")},function(){$(this).removeClass("top-ad-close-h")})
	
		   })


//收藏
function addFav(){
	if(document.all){
		try{
			window.external.addFavorite('http://www.esunny.com','宇商网');
		}catch(e){
			alert('您的浏览器不支持添加收藏，请使用浏览器菜单手动设置');
		}
	}else if(window.sidebar){
		window.sidebar.addPanel('宇商网', 'http://www.esunny.com', '');
	}else{
		alert('您的浏览器不支持添加收藏，请使用浏览器菜单手动设置');
	}
}
//设为首页
function setHp(){
	if (document.all){
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage('http://www.esunny.com');
	}else{
		//考虑到浏览器弹出窗的内容可能误导用户，现在把非IE浏览器下的设为首页功能屏蔽
		alert( "您的浏览器不支持自动设置主页，请使用浏览器菜单手动设置" );
	}
}


//搜索suggestion开始
(function( $, undefined ) {	
	$.ui = $.ui || {};

$.extend( $.ui, {
	version: "1.8.13",
	keyCode: {
		ALT: 18,
		BACKSPACE: 8,
		CAPS_LOCK: 20,
		COMMA: 188,
		COMMAND: 91,
		COMMAND_LEFT: 91, // COMMAND
		COMMAND_RIGHT: 93,
		CONTROL: 17,
		DELETE: 46,
		DOWN: 40,
		END: 35,
		ENTER: 13,
		ESCAPE: 27,
		HOME: 36,
		INSERT: 45,
		LEFT: 37,
		MENU: 93, // COMMAND_RIGHT
		NUMPAD_ADD: 107,
		NUMPAD_DECIMAL: 110,
		NUMPAD_DIVIDE: 111,
		NUMPAD_ENTER: 108,
		NUMPAD_MULTIPLY: 106,
		NUMPAD_SUBTRACT: 109,
		PAGE_DOWN: 34,
		PAGE_UP: 33,
		PERIOD: 190,
		RIGHT: 39,
		SHIFT: 16,
		SPACE: 32,
		TAB: 9,
		UP: 38,
		WINDOWS: 91 // COMMAND
	}
});
	
})(jQuery);	
var suggestionAjaxFlag;
     $(function(){
		if(location.host.indexOf("search.esunny.com")==(-1)&&location.host.indexOf("www.esunny.com")==(-1)&&location.host.indexOf("product.esunny.com")==(-1)){
		 return;
		
		}
	 $('<div class="search-suggest"><dl class="search-autocomplete"></dl></div>').appendTo(".search")
	 //搜索框事件
	 var searchtimer;
	 var _searchflag = true;
	 var _resulthoverflag = false;
	 var searchsave;
	 var _autocompleteTimer;
	 $("#txtSearch").bind({keyup:function(event){
	 //绑定键盘监听事件
	var self = $(this);
	var keyCode = $.ui.keyCode;
	switch( event.keyCode ) {
	case keyCode.UP:
		if(!suggestionAjaxFlag){
			return
		}
		if(_searchflag){
		$(".search-autocomplete dd").removeClass("cur")
		$(".search-autocomplete dd:last").addClass("cur")
		var _keytext = $(".search-autocomplete dd:last").find(".sa-key").text()
		self.val(_keytext)
		_searchflag = false;
		_resulthoverflag = true;
		}
		else{
		if($(".search-autocomplete dd").index($(".search-autocomplete dd").filter(".cur"))==0){
			return;
		}
		else{
			$(".search-autocomplete dd").filter(".cur").removeClass("cur").prev("dd").addClass("cur")
			var _keytext = $(".search-autocomplete .cur").find(".sa-key").text()
			self.val(_keytext)
		}
		
		}
		// prevent moving cursor to beginning of text field in some browsers
		event.preventDefault();
		return;
		break;
	case keyCode.DOWN:
		if(!suggestionAjaxFlag){
		return
		}
		if(_searchflag){
		$(".search-autocomplete dd").removeClass("cur")
		$(".search-autocomplete dd").eq(0).addClass("cur")
		var _keytext = $(".search-autocomplete dd").eq(0).find(".sa-key").text()
		self.val(_keytext)
		_searchflag = false;
		_resulthoverflag = true;
		}
		else{
			if($(".search-autocomplete dd").index($(".search-autocomplete dd").filter(".cur"))==($(".search-autocomplete dd").length-1)){
			return;
		}
		else{
			$(".search-autocomplete dd").filter(".cur").removeClass("cur").next("dd").addClass("cur")
			var _keytext = $(".search-autocomplete .cur").find(".sa-key").text()
		self.val(_keytext)
		}
		}
		event.preventDefault();
		return;
		break;
	case keyCode.ESCAPE:
		break;
	case keyCode.LEFT:
		break;
	case keyCode.RIGHT:
		break;			
	default:
		_autocompleteTimer = setTimeout("autocomplete()",500)
		_searchflag = true;
		break;
	}
	 },
	 blur:function(){
	 searchtimer =	setTimeout('searchsave = $(".search-suggest").html();$(".search-autocomplete").html("");$(".search-suggest").hide();suggestionAjaxFlag = false;',250)
	 
	 },
	 focus:function(){
	 clearTimeout(searchtimer)
	 },
	 keydown:function(){
		clearTimeout(_autocompleteTimer)
	 }
	 })
	 })
	 
	 function autocomplete(){
	 var keyword = $.trim($("#txtSearch").val())
	 //jsonP请求
	 var suggestUrl = encodeURI("http://search.esunny.com/smartsuggestion/query.htm?q="+keyword)
	 if(searchType==1&&keyword.length>0){
	 //json格式参考：========
	 //var json = {"result":[["_mp%3","404845"],["_名片%","292782"],["_mp%3耳机","221771"],["_名片%包","207817"],["_名片%印刷","204425"],["_铭牌%","117210"],["_mp%4","65779"],["_名片%盒","43038"],["_木皮%","32278"],["_面盆%","28464"],["_名片%夹","27657"]]}  
	 //请求数据
	$.ajax({
		   type: "get",
		   url: suggestUrl,
		   dataType: "jsonp",
		   jsonp: "callback",
		   cache:true,
		   success: function(data){
		   		var buffer = []
				if(data.result.length==0){
				$(".search-suggest").hide();	
				return;
				}
		   		jQuery.each(data.result,function(i){
				var _num = data.result[i][1];
				var _rr = /_(.*)%/g;
				var _text = data.result[i][0].replace(_rr,'<em>$1</em>');
				buffer.push('<dd><a><span class="sa-key">'+_text+'</span></a></dd>')	
				 })
				 suggestionAjaxFlag=true;
				 _resulthoverflag = false;
				$(".search-autocomplete").html($(buffer.join(""))).parent().show();	
				//绑定下拉菜单的鼠触事件
				$(".search-autocomplete dd").hover(function(){
					_searchflag = true;
					if(_resulthoverflag){
						$("#txtSearch").val(keyword);
					}
					$(".search-autocomplete dd").removeClass("cur")
					$(this).addClass("cur")
				 },function(){
					$(this).removeClass("cur")
				 }).bind("click",function(){
				 var _key = $(this).find(".sa-key").text();
				 $("#txtSearch").val(_key);
				 $("#search-btn").click();
				 })
		   },
		   error:function(){
		  	$(".search-autocomplete").html("")
	 		$(".search-suggest").hide();
		   }
		});
	 //请求数据结束
	 }
	 //不满足搜索条件，隐藏搜索结果
	 else{
	 	searchsave = $(".search-suggest").html()
		$(".search-autocomplete").html("")
	 	$(".search-suggest").hide();
	 }
	 }

//搜索suggestion结束



// 动态加载外部javaScript文件
function getScript(src, fn) {
	var script = document.createElement('script');
	script.language = "javascript";
	script.type = 'text/javascript';

	// 读取完后的操作
	script.onload = script.onreadystatechange = function() {
		if (!script.readyState || 'loaded' === script.readyState ||'complete' === script.readyState) {
			fn && fn();
			script.onload = script.onreadystatechange = null;
			script.parentNode.removeChild(script);
		};
	};
	
	script.src = src;
	// 不插入head是为了保证script标签在DOM中的顺序，以免获取自身scr路径的方法出错
	document.body.appendChild(script);
};

/**
* 统计代码
* date:2011-11-18
*/
//google统计变量
var _gaq = _gaq || [];

_gaq.push(['_setAccount', 'UA-17293683-1']);
_gaq.push(['_setDomainName', '.esunny.com']);
_gaq.push(['_addIgnoredRef', '.esunny.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_setAllowHash', false]);
_gaq.push(['_addOrganic', 'baidu', 'wd']);
_gaq.push(['_addOrganic', 'soso', 'w']);
_gaq.push(['_addOrganic', 'youdao', 'q']);
_gaq.push(['_addOrganic', 'sogou', 'q']);
_gaq.push(['_trackPageLoadTime']);

_gaq.push(['t1._setAccount', 'UA-17293683-39']);
_gaq.push(['t1._setDomainName', '.esunny.com']);
_gaq.push(['t1._addIgnoredRef', '.esunny.com']);
_gaq.push(['t1._setAllowLinker', true]);
_gaq.push(['t1._setAllowHash', false]);
_gaq.push(['t1._addOrganic', 'soso', 'w']);
_gaq.push(['t1._addOrganic', 'yodao', 'q']);
_gaq.push(['t1._addOrganic', 'sogou', 'q']);
_gaq.push(['t1._addOrganic', 'baidu', 'wd']);
_gaq.push(['t1._trackPageview']);
_gaq.push(['t1._trackPageLoadTime']);

function  GetanalyticCode(){
//google
getScript(('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js');
//CNZZ
//getScript('http://s19.cnzz.com/stat.php?id=2886139&web_id=2886139');
//baidu
getScript(('https:' == document.location.protocol ? 'https://' : 'http://') + 'hm.baidu.com/h.js?6c9575be66e5bc5d3c78d1c23a6b30f3');
//sougo
getScript(('https:' == document.location.protocol ? 'https://' : 'http://') + 
'hermes.sogou.com/sa.js?sid=13653-14139');

}

$(document).ready(function(){
var t = setTimeout('GetanalyticCode()',2000);
})
